<template>
  <div class="RightBottom">
    <TITLESS cnt="最新报警"></TITLESS>
    <div class="scrollBox">
      <header>
        <div>报警类型</div>
        <div>设备位置</div>
        <div>时间</div>
      </header>
      <div class="scrollContent" 
      @mouseover="handleMouseover($event)"
      @mouseout="handleMouseout($event)">
        <vue3-seamless-scroll :list="dataList" :hover="true" :step="0.7" :limitScrollNum="6">
          <div class="showBox" v-if="dataList.length">
            <div class="scrollItemBox" v-for="(item, i) in dataList" :key="i" >
              <div class="typeBox">
                <span :class="getColor(item.level)">{{
                  getType(item.level)
                }}</span>
              </div>
              <div>{{ item.location || '--'}}</div>
              <div>
                {{ day(item.createdDate).format('YY/MM/DD HH:mm')}}
              </div>
            </div>
          </div>
          <div v-else class="noWarn">暂无预警</div>
        </vue3-seamless-scroll>
      </div>
    </div>
  </div>
</template>

<script setup>
import TITLESS from "@/components/TITLESS.vue";
import emitter from '@/libs/mini3d/utils/mitt'
import { Vue3SeamlessScroll } from 'vue3-seamless-scroll'

defineProps({
  dataList: {
      type: Object,
      default: ()=> { return []}
    },
});

function getType(type) {
      switch (type) {
        case 10:
          return "高报";
        case 11:
          return "低报";
        case 6:
          return "故障";
        case 9:
          return "离线";
        default:
          return "- -";
      }
    }
function getColor(type) {
      switch (type) {
        case 10:
          return "level10";
        case 11:
          return "level11";
        case 6:
          return "level6";
        case 9:
          return "level9";
        default:
          return "- -";
      }
    }
function handleMouseover(){
  emitter.emit('mouseOver')
}

function handleMouseout(){
  emitter.emit('mouseOut')
}
// function defaultOption (){
//   return {
//         step: 0.6, // 数值越大速度滚动越快
//         limitMoveNum: 6, // 开始无缝滚动的数据量 this.dataList.length
//         hoverStop: true, // 是否开启鼠标悬停stop
//         direction: 1, // 0向下 1向上 2向左 3向右
//         openWatch: true, // 开启数据实时监控刷新dom
//         singleHeight: 0, // 单步运动停止的高度(默认值0是无缝不停止的滚动) direction => 0/1
//         singleWidth: 0, // 单步运动停止的宽度(默认值0是无缝不停止的滚动) direction => 2/3
//         waitTime: 1000, // 单步运动停止的时间(默认值1000ms)
//       }
// }

</script>

<style lang="scss" scoped>
::v-deep .level3 {
  margin-left: 100px !important;
}
::v-deep .val1 {
  width: 100px !important;
}

.on {
  background: #133251;
}
.off {
  background: transparent;
}
.RightBottom {
  height: calc(100% - 45px); 
  position: relative;
  .more {
    position: absolute;
    right: 100px;
  }
}
.scrollBox {
  width: 100%;
  height: 100%;
  // margin-bottom: 30px;
  padding: 20px 0;

  header {
    width: 100%;
    height: 50px;
    font-size: 18px;
    padding: 0 20px;
    box-sizing: border-box;
    font-family: Arial;
    background: #022752;
    color: #96d0ff;
    display: flex;
    // justify-content: space-around;
    text-align-last: left;
    align-items: center;
    div {
      &:nth-child(1) {
        width: 25%;
      }
      &:nth-child(2) {
        width: 45%;
      }
      &:nth-child(3) {
        width: 30%;
      }
    }
  }

  .scrollContent {
    width: 100%;
    height: 300px;
    overflow: hidden;

    .scrollItemBox {
      height: 45px;
      padding: 0 20px;
      box-sizing: border-box;
      display: flex;
      // justify-content: space-around;
      text-align-last: left;
      align-items: center;
      div {
        font-size: 14px;
        color: #d1eaff;
        &:nth-child(1) {
          width: 25%;
        }
        &:nth-child(2) {
          width: 45%;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
          padding-right: 20px;
          box-sizing: border-box;
        }
        &:nth-child(3) {
          width: 30%;
        }
      }
      &:nth-child(2n) {
        // background: rgba(67, 128, 155, 0.2);
        background: #0a112e;
      }

      .ctn {
        // width: 200px;
        // line-height: 25px;
        display: flex;
        align-items: center;

        img {
          width: 20px;
          height: 18px;
          margin-right: 10px;
        }
      }
      .typeBox {
        span {
          border: 1px solid #fff;
          padding: 5px;
          border-radius: 5px;
        }
        .level10 {
          color: #2B8EF3;
          border-color: #2B8EF3;
        }
        .level11 {
          color: #FF6E77;
          border-color: #FF6E77;
        }
        .level6 {
          color: #FED36A;
          border-color: #FED36A;
        }
        .level9 {
          color: #BCC8D6;
          border-color: #BCC8D6;
        }
      }
    }
    .noWarn {
      width: 100%;
      text-align: center;
      color: rgba(209, 234, 255, 1);
      font-size: 18px;
      line-height: 48px;
    }
  }
}


.scroll {
  height: 270px;
  width: 500px;
  margin: 100px auto;
  overflow: hidden;
}

.scroll .item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 0;
}
</style>
 